Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
boot-in-the-arse
Advanced tools
Asynchronous bootstrapping made easy. Wait for all components/plugins to start, and then start your whole app.
boot-in-the-arse
is fully reentrant and graph-based. You can load
components/plugins within plugins, and be still sure that things will
happen in the right order.
To install boot-in-the-arse
, simply use npm:
npm install boot-in-the-arse --save
The example below can be found here and ran using node example.js
. It
demonstrates how to use boot-in-the-arse
to load functions /
plugins in
order.
'use strict'
const boot = require('boot-in-the-arse')()
boot
.use(first, { hello: 'world' })
.after((cb) => {
console.log('after first and second')
cb()
})
.use(third, (err) => {
if (err) {
console.log('something bad happened')
console.log(err)
}
console.log('third plugin loaded')
})
.ready(function () {
console.log('application booted!')
})
function first (instance, opts, cb) {
console.log('first loaded', opts)
instance.use(second, cb)
}
function second (instance, opts, cb) {
console.log('second loaded')
process.nextTick(cb)
}
function third (instance, opts, cb) {
console.log('third loaded')
cb()
}
Start a booting sequence.
instance
will be used as the first
argument of all plugins loaded and use
, after
and ready
function will be
added to that object, keeping the support for the chainable API:
const server = {}
require('boot-in-the-arse')(server)
server.use(function first (s, opts, cb) {
// s is the same of server
s.use(function second (s, opts, cb) {
cb()
}, cb)
}).after(function (cb) {
// after first and second are finished
cb()
})
Options:
expose
: a key/value property to change how use
, after
and ready
are exposed.Events:
'error'
if something bad happens'start'
when the application startsThe boot
function can be used also as a
constructor to inherits from.
Loads a functions asynchronously. The function must have the signature:
function plugin (server, opts, done) {
done()
}
done
must be called only once.
Returns the instance on which use
is called, to support a
chainable API.
If you need to add more than a function and you don't need to use a different options object or callback, you can pass an array of functions to .use
.
boot.use([first, second, third], opts, cb)
The functions will be loaded in the same order as they are inside the array.
Calls a functon after all the previously defined plugins are loaded, including
all their dependencies. The 'start'
event is not emitted yet.
boot.after(function (done) {
done()
})
done
must be called only once.
Returns the instance on which after
is called, to support a
chainable API.
Calls a functon after all the plugins and after
call are
completed, but befer 'start'
is emitted. ready
callbacks are
executed one at a time.
boot.ready(function (done) {
done()
})
done
must be called only once.
Returns the instance on which ready
is called, to support a
chainable API.
Same as:
const app = express()
boot(app, {
expose: {
use: 'load'
}
})
This project was kindly sponsored by nearForm.
Copyright Matteo Collina 2016, Licensed under MIT.
FAQs
Asynchronous bootstrapping of Node applications
The npm package boot-in-the-arse receives a total of 0 weekly downloads. As such, boot-in-the-arse popularity was classified as not popular.
We found that boot-in-the-arse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.